package bzqn.com.rongcloudsdk;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import bzqn.com.rongcloudsdk.utils.DialogUtils;

public class MeasureActivity extends BaseActivity {

    //获取量鱼最终的尺寸
    public float getRfHeightCM(float ref){
        float p1H = mImageView.getPixLengthWithP1();
        float p2H = mImageView.getPixLengthWithP2();
        return (p2H/p1H)*ref;
    }
    private DrawLineImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_measure);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("量鱼");
        setSupportActionBar(toolbar);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.done:
                        toMeasure();
                        break;
                    default:
                        break;
                }
                return true;
            }
        });
        initView();
    }

    public void toMeasure(){
        DialogUtils.showToast("完成");
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    public void saveImageClick(View view){
        float h =  getRfHeightCM(ObjectReference.RF_1);
        Log.i("height",h+"");
    }
    public void resetClick(View view){
        mImageView.reset();
    }
    public void helpClick(View view){
        //TODO:帮助按钮
    }
    private void initView() {
        mImageView = (DrawLineImageView) findViewById(R.id.me_image);
    }

    public static void startActivity(Context context) {
        context.startActivity(new Intent(context,MeasureActivity.class));
    }
}
